package engine.systems.collision.platform
{
	import ash.core.Engine;
	import ash.core.NodeList;
	import ash.core.System;
	
	import engine.classes.enumerations.SystemPriority;
	import engine.utils.EntityUtils;
	
	/**
	 * BROKEN
	 */
	public class PlatformCollisionSystem extends System
	{
		private var colliders:NodeList;
		private var platforms:NodeList;
		
		public function PlatformCollisionSystem()
		{
			this.priority = SystemPriority.COLLISION;
		}
		
		override public function update(time:Number):void
		{
			for(var platform:PlatformNode = this.platforms.head; platform; platform = platform.next)
			{
				if(EntityUtils.sleeping(platform.entity)) continue;
				
				for(var collider:PlatformCollisionNode = this.colliders.head; collider; collider = collider.next)
				{
					if(EntityUtils.sleeping(collider.entity)) continue;
					
					if(collider.motion.velocityY > 0)
					{
						
					}
				}
			}
		}
		
		override public function addToEngine(systemManager:Engine):void
		{
			this.colliders = systemManager.getNodeList(PlatformCollisionNode);
			this.platforms = systemManager.getNodeList(PlatformNode);
		}
		
		override public function removeFromEngine(systemManager:Engine):void
		{
			systemManager.releaseNodeList(PlatformCollisionNode);
			systemManager.releaseNodeList(PlatformNode);
			
			this.colliders = null;
			this.platforms = null;
		}
	}
}